<?php

namespace App\Http\Middleware;

use Closure;

class SetRequestParameter
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @param null $key
     * @param null $value
     * @return mixed
     */
    public function handle($request, Closure $next, $key = '')
    {
        if ($key) {
            parse_str($key, $arr);
            $request->merge($arr);
        }
        return $next($request);
    }
}
